package com.jsb.laundry.controller;

import com.github.pagehelper.PageHelper;
import com.jsb.laundry.common.constant.CommonConstants;
import com.jsb.laundry.common.constant.JSBSpecialID;
import com.jsb.laundry.common.design_service.pay.properties.WechatMiniPayProperties;
import com.jsb.laundry.common.enums.OrderStatus;
import com.jsb.laundry.common.enums.ReturnStatusCode;
import com.jsb.laundry.common.exception.BusinessException;
import com.jsb.laundry.common.mq.WaitPayConfig;
import com.jsb.laundry.common.response.BaseRequestParam;
import com.jsb.laundry.common.response.WebResponse;
import com.jsb.laundry.common.utils.JSBUtil;
import com.jsb.laundry.common.utils.OrderCommonUtil;
import com.jsb.laundry.common.utils.TimeConversionUtil;
import com.jsb.laundry.common.utils.id.IDUtil;
import com.jsb.laundry.common.utils.redis.RedisUtil;
import com.jsb.laundry.dao.ActivityDao;
import com.jsb.laundry.dao.OrderDao;
import com.jsb.laundry.model.dto.*;
import com.jsb.laundry.model.entity.*;
import com.jsb.laundry.model.vo.ConfirmOrderPageVo;
import com.jsb.laundry.model.vo.LaundryOrderDetailVo;
import com.jsb.laundry.model.vo.PrePayVo;
import com.jsb.laundry.model.vo.UserOrderList;
import com.jsb.laundry.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

@Api(tags = {"订单服务"})
@RestController
@RequestMapping("/userOrder")
public class OrderController extends BaseController {
    private static final Logger LOGGER = LoggerFactory.getLogger(OrderController.class);

    private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("MM-dd");
    private static final DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");

    @Resource
    private WechatMiniPayProperties wechatMiniPayProperties;
    @Resource
    private OrderService orderService;

    @Resource
    private RedisUtil redisUtil;

    @Resource
    private RabbitTemplate rabbitTemplate;

    @Resource
    private OrderDao orderDao;

    @Resource
    private ActivityDao activityDao;

    /**
     * 用户下单轮播提示
     */
    @PostMapping("userBuyInfo")
    public WebResponse userBuyInfo() {
        List<UserBuyInfo> userBuyInfos = orderDao.userBuyInfo();
        for (UserBuyInfo userBuyInfo : userBuyInfos) {
            if (userBuyInfo.getUserPhone() != null) {
                userBuyInfo.setUserPhone(JSBUtil.maskPhoneNumber(userBuyInfo.getUserPhone()));
                userBuyInfo.setPayDate(TimeConversionUtil.format(userBuyInfo.getPayTime()));
            }

        }
        return WebResponse.successData(userBuyInfos);
    }

    /**
     * 去确认订单页面(userId、currentTime、orderInfoList)
     */
    @ApiOperation(value = "去确认订单页面", notes = "去确认订单页面", httpMethod = "POST")
    @PostMapping("/toConfirmOrderPage")
    public WebResponse toConfirmOrderPage(@RequestBody OrderInfoRequest orderInfoRequest) {
        LOGGER.info("去确认订单页面" + orderInfoRequest);
        //userId
        String userId = orderInfoRequest.getUserId();
        //用户下单的信息
        List<PayModeRequest.OrderInfo> orderInfoList = orderInfoRequest.getOrderInfoList();
        //参数判空
        if (JSBUtil.isEmptyString(userId) || JSBUtil.isEmptyCollection(orderInfoList)) {
            return WebResponse.failOfParameter();
        }
        //生成预约时间data
        Date currentTime = orderInfoRequest.getCurrentTime() == null ? new Date() : orderInfoRequest.getCurrentTime();
        //获取用户地址列表
        List<ConfirmOrderPageVo.UserAddressVo> userAddressInfo = orderDao.findUserAddressByUserId(userId);
        //获取vip套餐
        List<ConfirmOrderPageVo.CouponVo> vipPackageInfo = orderDao.getVipPackageInfo();
        //获取是否购买过优惠券
        String vipFlag = orderDao.getUserCouponUsableNum(userId);
        //获取订单中商品信息
        ConfirmOrderPageVo serveInfo = orderService.calOrderGoodsInfo(new PayModeRequest().setOrderInfoList(orderInfoList).setCardId(null));

        ConfirmOrderPageVo confirmOrderPageVo = new ConfirmOrderPageVo();
        confirmOrderPageVo
                .setAppointmentTimeList(OrderCommonUtil.getTime(currentTime))
                .setAddressInfo(userAddressInfo)
                .setCouponInfo(vipPackageInfo)
                .setVipFlag(vipFlag)
                .setServeInfo(serveInfo.getServeInfo())
                .setBuyNumTotal(serveInfo.getBuyNumTotal())
                .setTotal(serveInfo.getTotal())
                .setOriginalPrice(serveInfo.getOriginalPrice())
                .setDiscountTotal(serveInfo.getDiscountTotal())
                .setEquityExplain(serveInfo.getEquityExplain());

        return WebResponse.successData(confirmOrderPageVo);
    }

    /**
     * 数据 保存 订单表
     *
     * @param data
     * @return
     */
    @PostMapping("/orderDataSave")
    @Transactional(rollbackFor = Exception.class)
    public WebResponse orderDataSave(@RequestBody CreateOrderRequest data) {
        String userId = data.getUserId();  //userId
        String cardId = data.getCardId();  //使用的卡券id
        String userAddressComeId = data.getUserAddressComeId();// 上门地址id
        String userAddressBackId = data.getUserAddressBackId();// 送回地址id
        UserAddress userAddressComeInfo = orderDao.findUserAddressByID(userId, userAddressComeId); //上门取衣地址
        UserAddress userAddressBackInfo = orderDao.findUserAddressByID(userId, userAddressBackId); //衣物送回地址
        Date appointmentTime = data.getAppointmentTime();// 用户预约上门时间
        String appointmentTimeStr = data.getAppointmentTimeStr();
        List<PayModeRequest.OrderInfo> orderInfoList = data.getOrderInfoList();//用户下单的商品信息

        if (JSBUtil.isEmptyString(userId) || JSBUtil.isEmptyCollection(orderInfoList)
                || JSBUtil.isEmptyObject(userAddressComeInfo) || JSBUtil.isEmptyObject(userAddressBackInfo)) {
            return WebResponse.failOfParameter();
        }
        List<String> goodsIdList = orderInfoList.stream().map(PayModeRequest.OrderInfo::getGoodsId).collect(Collectors.toList());

        /**
         * TODO 订单id生成
         */
        String orderId = "";
        if (goodsIdList.containsAll(JSBSpecialID.SCHOOL_MONTH)) {
            orderId = CommonConstants.SCHOOL_ORDER_PREFIX + IDUtil.getPayId();
        } else if (JSBSpecialID.JSB_MONTH_1_298.equals(goodsIdList.get(0)) || JSBSpecialID.JSB_MONTH_2_398.equals(goodsIdList.get(0))) {
            orderId = CommonConstants.MONTH_CARD_USE_PREFIX + IDUtil.getPayId(); //使用月卡时填充的支付id
        } else if (goodsIdList.containsAll(JSBSpecialID.ACTIVITY_LIST_ID)) {
            orderId = CommonConstants.ACTIVITY_ORDER_PREFIX + IDUtil.getPayId();
        } else {
            orderId = CommonConstants.ORDER_PREFIX + IDUtil.getPayId();
        }

        //计算价格-----------------------------------
        List<PayModeRequest.OrderInfo> productInfoList = orderDao.getOrderProductInfo(orderInfoList);
        //同步laundryInfo的购买量
        productInfoList.forEach(var0 -> orderInfoList.stream()
                .filter(detail -> detail.getServeId().equals(var0.getServeId()))
                .findFirst()
                .ifPresent(detail -> var0.setBuyNum(detail.getBuyNum())));

        Integer cardFaceValue = 0;
        if (!JSBUtil.isEmptyString(data.getCardId()) &&
                !(JSBSpecialID.SCHOOL_MONTH_ID.equals(goodsIdList.get(0)) || JSBSpecialID.JSB_MONTH_1_298.equals(goodsIdList.get(0)) || JSBSpecialID.JSB_MONTH_2_398.equals(goodsIdList.get(0)))) {
            //使用优惠券,获取用户使用的优惠券的面值
            cardFaceValue = orderDao.findCoupon(userId, cardId);
            data.setVipCardId(data.getCardId());
        } else if (!JSBUtil.isEmptyString(data.getCardId()) &&
                (JSBSpecialID.JSB_MONTH_1_298.equals(goodsIdList.get(0)) || JSBSpecialID.JSB_MONTH_2_398.equals(goodsIdList.get(0)))) {
            //月卡使用
            data.setMonthCardId(data.getCardId());
        } else if (!JSBUtil.isEmptyString(data.getCardId()) && JSBSpecialID.SCHOOL_MONTH_ID.equals(goodsIdList.get(0))) {
            //校服使用
            data.setSchoolCardId(data.getCardId());
        }

        //商品总量
        int num = productInfoList.stream()
                .mapToInt(PayModeRequest.OrderInfo::getBuyNum)
                .reduce(0, Integer::sum);

        //子订单商品总价
        int subOrderTotal = productInfoList.stream()
                .mapToInt(orderInfo -> orderInfo.getBuyNum() * Integer.parseInt(orderInfo.getServePrice()))
                .sum();
        ConfirmOrderPageVo serveInfo = orderService.calOrderGoodsInfo(new PayModeRequest().setOrderInfoList(orderInfoList).setUserId(userId).setCardId(data.getVipCardId()));

        /**
         * TODO 是否有邀请人,有打9折，仅限分类中的商品
         */
        String riderPromotionId = orderDao.getRiderPromotion(userId);
        if (serveInfo != null && !JSBUtil.isEmptyString(riderPromotionId)) {
            if (!(goodsIdList.containsAll(JSBSpecialID.SCHOOL_MONTH) || JSBSpecialID.JSB_MONTH_1_298.equals(goodsIdList.get(0))
                    || JSBSpecialID.JSB_MONTH_2_398.equals(goodsIdList.get(0)) || goodsIdList.containsAll(JSBSpecialID.ACTIVITY_LIST_ID))) {
                double s = Integer.parseInt(JSBUtil.turnIntegerStr(serveInfo.getTotal())) * 0.9;
                serveInfo.setTotal(String.valueOf(s / 100));
            }

        }

        /**
         * TODO 父订单
         */
        LocalDateTime createAt = LocalDateTime.now();
        JsbOrders parentOrderInfo = new JsbOrders();
        parentOrderInfo.setOrderId(orderId).setUserId(userId).setAppointmentTime(appointmentTime).setAppointmentTimeStr(appointmentTimeStr).setOrderType("1").setOrdersName(productInfoList.get(0).getGoodsName())
                .setNum(num).setOrderNumber(num).setOrdersImg(productInfoList.get(0).getGoodsImg())
                .setTotalItemsPrice(subOrderTotal).setTotalPrice(subOrderTotal).setPaidPrice(Integer.parseInt(JSBUtil.turnIntegerStr(serveInfo.getTotal()))).setDiscountPrice(Integer.parseInt(JSBUtil.turnIntegerStr(serveInfo.getDiscountTotal())))
                .setVoucherId(cardId).setHasUsedVoucher(JSBUtil.isEmptyString(cardId) ? 0 : 1).setNote(data.getNote()).setOrderSource("1").setOrderDirection("1")
                .setOrderStatus(OrderStatus.WAIT_PAY.getCode()).setDelFlag("0").setCreatedAt(Date.from(createAt.atZone(ZoneId.systemDefault()).toInstant())).setPayTimeoutAt(Date.from(createAt.plusMinutes(30).atZone(ZoneId.systemDefault()).toInstant()));
        int var0 = orderDao.preParentOrder(parentOrderInfo);
        if (var0 == 0) {
            throw new BusinessException(ReturnStatusCode.SAVE_ERROR);
        }


        /**
         * TODO 子订单列表
         *
         */
        List<JsbOrdersItem> subOrderList = new ArrayList();
        //把每一件商品平铺到订单表中，一件商品买了3件也添加3条数据到数据库中
        for (PayModeRequest.OrderInfo order : productInfoList) {
            int buyNum = order.getBuyNum();
            if (buyNum > 1) {
                for (int i = 0; i < buyNum; i++) {
                    JsbOrdersItem subOrderInfo = new JsbOrdersItem();
                    PayModeRequest.OrderInfo subOrder = (PayModeRequest.OrderInfo) order.clone();

                    subOrderInfo.setOrderId(orderId).setSubOrderId(IDUtil.getOrderId())
                            .setProductId(subOrder.getGoodsId()).setTitle(subOrder.getGoodsName())
                            .setPrice(Integer.parseInt(subOrder.getServePrice())).setQuantity(1)
                            .setImg(subOrder.getGoodsImg()).setServeId(subOrder.getServeId());

                    subOrderList.add(subOrderInfo);
                }
            } else {
                JsbOrdersItem subOrderInfo = new JsbOrdersItem();
                subOrderInfo.setOrderId(orderId).setSubOrderId(IDUtil.getOrderId())
                        .setProductId(order.getGoodsId()).setTitle(order.getGoodsName())
                        .setPrice(Integer.parseInt(order.getServePrice())).setQuantity(1)
                        .setImg(order.getGoodsImg()).setServeId(order.getServeId());
                subOrderList.add(subOrderInfo);
            }
        }

        int var1 = orderDao.preSubOrder(subOrderList);
        if (var1 == 0) {
            throw new BusinessException(ReturnStatusCode.SAVE_ERROR);
        }

        /**
         * TODO 用户预约信息
         *
         */
        JsbOrdersShippingAddresses userAppointmentInfo = new JsbOrdersShippingAddresses();
        userAppointmentInfo.setOrderId(orderId)
                .setPickupName(userAddressComeInfo.getUserName()).setPickupMobile(userAddressComeInfo.getUserPhone()).setPickupAddress(userAddressComeInfo.getUserAddress() + userAddressComeInfo.getUserDetailAddress()) // 上门取衣地址及信息
                .setDeliveryName(userAddressBackInfo.getUserName()).setDeliveryMobile(userAddressBackInfo.getUserPhone()).setDeliveryAddress(userAddressBackInfo.getUserAddress() + userAddressBackInfo.getUserDetailAddress()); // 衣物送回地址及信息
        int var3 = orderDao.preAppointmentInfo(userAppointmentInfo);
        if (var3 == 0) {
            throw new BusinessException(ReturnStatusCode.SAVE_ERROR);
        }

        /**
         * TODO 订单支付信息
         */
        JsbOrdersTransactions ordersPay = new JsbOrdersTransactions(); //订单支付信息
        ordersPay.setTransId(CommonConstants.PAY_PREFIX + IDUtil.getOrderId()).setOrderId(orderId)
                .setUserId(userId).setAmount(parentOrderInfo.getPaidPrice());
        int var4 = orderDao.preTransaction(ordersPay);
        if (var4 == 0) {
            throw new BusinessException(ReturnStatusCode.SAVE_ERROR);
        }

        //使用了月卡
        if (!JSBUtil.isEmptyString(data.getMonthCardId())) {
            //调整月卡状态为已使用
            int var00 = orderDao.updMonthCardUseStatus(userId, data.getMonthCardId());
            //调整订单状态...
            JsbOrdersShippingAddresses jsbOrdersShippingAddresses = new JsbOrdersShippingAddresses();
            jsbOrdersShippingAddresses.setPickupMobile(userAddressComeInfo.getUserPhone()).setPickupName(userAddressComeInfo.getUserName()).setPickupAddress(userAddressComeInfo.getUserAddress() + userAddressComeInfo.getUserDetailAddress());
            parentOrderInfo.setUserAddress(jsbOrdersShippingAddresses);
            int var01 = orderService.updParentOrderInfo(parentOrderInfo);
            paymentNoticeRider(orderId);
        } else if (!JSBUtil.isEmptyString(data.getSchoolCardId())) {
            //校验校服卡券使用时间
            String useFlag = orderDao.getSchoolCardInfo(data.getSchoolCardId());
            if (useFlag == null || "1".equals(useFlag)) { //卡券不可用
                throw new BusinessException(ReturnStatusCode.SCHOOL_CARD_UNUSABLE);
            }

            //把校服卡券状态更改为已使用
            ActivityDetail activityDetail = new ActivityDetail();
            activityDetail.setUserId(userId).setHoldSchoolCardId(data.getSchoolCardId());
            int ok = activityDao.updUseSchoolCard(activityDetail);

            //调整订单状态...
            JsbOrdersShippingAddresses jsbOrdersShippingAddresses = new JsbOrdersShippingAddresses();
            jsbOrdersShippingAddresses.setPickupMobile(userAddressComeInfo.getUserPhone()).setPickupName(userAddressComeInfo.getUserName()).setPickupAddress(userAddressComeInfo.getUserAddress() + userAddressComeInfo.getUserDetailAddress());
            parentOrderInfo.setUserAddress(jsbOrdersShippingAddresses);
            int var01 = orderService.updParentOrderInfo(parentOrderInfo);
            paymentNoticeRider(orderId);

        }

        //把实际支付金额存入redis中
        ProductInfoMapDto productInfoMapDto = new ProductInfoMapDto();
        productInfoMapDto.setUserId(userId).setOrderId(orderId)
                .setTotal(Integer.parseInt(JSBUtil.turnIntegerStr(serveInfo.getTotal()))).setProductType(getProductType(goodsIdList))
                .setCallbackUrl(wechatMiniPayProperties.getLaundryCallbackUrlCartOrActivity()).setCouponCardId(data.getVipCardId());
        redisUtil.setCacheObject(CommonConstants.TIMEOUT30_WAIT_PAY_ORDER + orderId, productInfoMapDto, 30, TimeUnit.MINUTES);


        PrePayVo prePayVo = new PrePayVo().setOrderId(orderId).setUserId(userId);
        //丢到mq中30分钟未支付，改变订单状态
        rabbitTemplate.convertAndSend(WaitPayConfig.ORDER_30_CANCEL_EXCHANGE, WaitPayConfig.ORDER_30_CANCEL_ROUTING_KEY,
                prePayVo, msg -> {
                    msg.getMessageProperties().setDelay(CommonConstants.ORDER_TIME_OUT);
                    return msg;
                });
        /**
         * 订单状态日志
         */
        addOrderStatusLog(orderId, OrderStatus.WAIT_PAY, OrderStatus.ORDER_DIRECTION1.getMsg());
        return WebResponse.successData(prePayVo);
    }


    /**
     * 获取订单列表 (userId、status、keyword、pageNum、pageSize)
     */
    @ApiOperation(value = "订单列表", notes = "用户订单列表", httpMethod = "POST")
    @PostMapping("/getOrderListByUserId")
    public WebResponse<List<UserOrderList>> getOrderListByUserId(@RequestBody OrderInfoDto orderInfoDto) {
        String userId = orderInfoDto.getUserId();
        String status = orderInfoDto.getStatus();
        if (JSBUtil.isEmptyString(userId) || JSBUtil.isEmptyString(status)) {
            return WebResponse.failOfParameter();
        }

        PageHelper.startPage(orderInfoDto.getPageNum(), orderInfoDto.getPageSize());
        List<UserOrderList> returnMsg = orderDao.getOrderListByUserId(userId, status, orderInfoDto.getKeyword());

        return WebResponse.successData(returnMsg);
    }

    /**
     * 查看订单详情(userId、orderId)
     */
    @ApiOperation(value = "订单详情", notes = "订单详情", httpMethod = "POST")
    @PostMapping("/orderDetail")
    public WebResponse orderDetail(@RequestBody OrderDetailRequest orderDetailRequest) {
        LOGGER.info("查看订单详情" + orderDetailRequest);
        //参数判空
        if (JSBUtil.isEmptyString(orderDetailRequest.getOrderId()) || JSBUtil.isEmptyString(orderDetailRequest.getUserId())) {
            return WebResponse.failOfParameter();
        }

        // 订单中用户信息
        LaundryOrderDetailVo orderDetail = orderDao.orderDetail1(orderDetailRequest.getUserId(), orderDetailRequest.getOrderId());
        LaundryOrderDetailVo.InnerUserInfo userInfo = orderDao.orderDetail2(orderDetailRequest.getUserId(), orderDetailRequest.getOrderId());
        List<LaundryOrderDetailVo.InnerRiderInfo> riderInfo = orderDao.orderDetail3(orderDetailRequest.getOrderId());
        List<LaundryOrderDetailVo.InnerOrderInfo> productInfo = orderDao.orderDetail4(orderDetailRequest.getOrderId());
        orderDetail.setUserInfo(userInfo).setRiderInfo(riderInfo).setOrderInfoList(productInfo);
        return WebResponse.successData(orderDetail);
    }


    /**
     * 获取当前时间后7天 8:00~20:00
     */
    @PostMapping("/getTime")
    public WebResponse getTime(@RequestBody BaseRequestParam requestParamBody) {
        LOGGER.info("获取当前时间后7天" + requestParamBody.getCurrentTime());
        Date currentTime = requestParamBody.getCurrentTime();
        //currentTime 请求参数判空
        if (JSBUtil.isEmptyObject(currentTime)) {
            return WebResponse.failOfParameter();
        }

        // 将Date转换为Instant，并使用默认时区创建LocalDateTime
        LocalDateTime now = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());

        List<CurrentTimeDto> returnList = new ArrayList<>();

        for (int i = 0; i < 7; i++) {
            CurrentTimeDto currentTimeResult = new CurrentTimeDto();
            LocalDateTime currentDay = now.plusDays(i);
            currentTimeResult.setText(dateFormatter.format(currentDay));
            currentTimeResult.setValue(currentDay.plusHours(1).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - 1);
//            currentTimeResult.setValue(currentDay.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - 1);

            int k = currentDay.getHour();
            for (int j = 0; j < 24 - currentDay.getHour(); ) {

                currentDay = currentDay.withMonth(currentDay.getMonthValue()).withDayOfMonth(currentDay.getDayOfMonth()).withHour(8).withMinute(0);

                CurrentTimeDto var1 = new CurrentTimeDto();

                LocalDateTime currentHours = currentDay.plusHours(j);
                j += 2;

                var1.setText(timeFormatter.format(currentHours) + " - " + timeFormatter.format(currentDay.plusHours(j)));
                var1.setValue(currentHours.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
//                var1.setValue(currentHours.plusHours(1).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());

                //配送时间(8:00~20:00)
                if (currentHours.getHour() >= 20 || currentHours.getHour() < 8) {
                    break;
                } else {
                    currentTimeResult.getChildren().add(var1);
                }

            }
            returnList.add(currentTimeResult);
        }
        long time = currentTime.getTime();
        CurrentTimeDto currentTimeDto = returnList.get(0);
        Long currentTimeStamp = currentTimeDto.getValue();
        List<CurrentTimeDto> children = currentTimeDto.getChildren();
        int index = -1;
        for (int i = 0; i < children.size(); i++) {
            if (children.get(i).getValue() >= time) { //找到当前时间所处的时间段
                index = i - 1;
                break;
            }
        }
        if (index == -1) {
            returnList.remove(0);
        } else {
            List<CurrentTimeDto> subChildren = children.subList(index, children.size());
            currentTimeDto.setValue(time - 1);
            subChildren.get(0).setValue(time);
            currentTimeDto.setChildren(subChildren);
            returnList.set(0, currentTimeDto);
        }

        return WebResponse.successData(returnList);
    }

    /**
     * 不同状态订单数量(userId)
     *
     * @param data
     * @return
     */
    @RequestMapping(value = "/diffOrderStatusNum")
    public WebResponse diffOrderStatusNum(@RequestBody BaseRequestParam data) {
        LOGGER.info("不同状态订单数量,{}", data);
        //请求参数判空
        if (JSBUtil.isEmptyString(data.getParam())) {
            return WebResponse.failOfParameter();
        }
        return WebResponse.successData(orderService.diffOrderStatusNum(data.getParam()));
    }


    /**
     * 团单
     *
     * @param workOrder
     * @return
     */
    @PostMapping("/addWorkOrder")
    public Integer add(@RequestBody WorkOrder workOrder) {
        int insert = orderDao.addWorkOrder(workOrder);
        return insert;
    }


}
